<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<#include "/admin/include/treeHead.htm">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
		<script type="text/javascript">
		var zTree = null;
		$(function() {
			$("#categoryTree").height($(window).height());
			var setting = {
				async: {
					enable: true,
					url: base + "/admin/b2c/goodsCategory/treeData.jhtml",
					autoParam: ["id = parentId"]
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				callback: {
					onDblClick: dblClick
				}
			};
			zTree = $.fn.zTree.init($("#categoryDemo"), setting);
		});
		//双击事件处理
		function dblClick(event, treeId, treeNode, clickFlag) {
			if(treeNode.treeLevel == 1) {
				parent.$("#goodsCategoryId").val(treeNode.id);
				parent.$("#goodsCategoryName").val(treeNode.name);
				parent.goodsCategoryTree.hide();
			}
		}

		parent.selectCategory = function() {
			var treeNodeArray = zTree.getSelectedNodes();
			if(treeNodeArray.length < 1) {
				return;
			}
			var treeNode = treeNodeArray[0];
			if(treeNode.treeLevel == 1) {
				parent.$("#goodsCategoryId").val(treeNode.id);
				parent.$("#goodsCategoryName").val(treeNode.name);
				parent.goodsCategoryTree.hide();
			}
		}
		</script>
	</head>
<body>
	<div id="categoryTree" style="overflow:hidden">
		<ul id="categoryDemo" class="ztree" style="overflow:auto;"></ul>
	</div>
</body>
</html>